package com.shengyuan.manage_os.old.ying.erpm;

import org.json.JSONException;

import com.shengyuan.manage_os.R;
import com.shengyuan.manage_os.old.ying.erpm.controls.PictureButton;
import com.shengyuan.manage_os.old.ying.erpm.util.Utility;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class Actual_OA_WorkDialy extends BaseActivity {

	protected PictureButton PictureButton_workdialy;
	protected EditText editText_workplay, editText_advice, editText_problem;
	

	@Override
	public void onClick(View view) {
		super.onClick(view);
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.actual_oa_workdialy);
		InitControls();
	}

	@Override
	protected void SaveJsonData() {
		try {
			IsJson1 = true; mFinished = 1; mPrintenabled= 0;
			JsonMyID();
			getZhongLiang();
			
			getCurrentUser();		
			getMemo();
			JsonPicture();
			JsonPicture_Ext();
		}catch (Exception e) {
		}
	}
	
	@Override
	protected void onResume() {
		PictureButton_workdialy.postInvalidate();
		super.onResume();
	}
	protected void getZhongLiang() throws JSONException {
		if (editText_workplay!=null) {
			mJson.put( getString(R.string.title_actual_oa_workdialy), editText_workplay.getText().toString());
		}
		if (editText_advice!=null) {
			mJson.put( getString(R.string.title_actual_oa_advice), editText_advice.getText().toString());
		}
		if (editText_problem!=null) {
			mJson.put( getString(R.string.title_actual_oa_problem), editText_problem.getText().toString());
		}
	}
	
	protected void JsonPicture_Ext() throws JSONException {
		if (PictureButton_workdialy!=null) {
			mJson.put( PictureButton_workdialy.FIELD+getString(R.string.title_actual_form_PictureButton), PictureButton_workdialy.mFileName);
		}
	}	
	@Override
	protected void SaveSelfPic(String sPath) {
		try {
			CopyPicDest(PictureButton_workdialy, sPath);
		} catch (Exception e) {
			Utility.MessageBox(this,e.getMessage());
		}
	}

	@Override
	public void Back() {
		super.Back();
	}

	@Override
	public void InitControls() {
		super.InitControls();
		editText_workplay = (EditText) findViewById(R.id.editText_workplay);
		editText_advice =(EditText) findViewById(R.id.editText_advice);
		editText_problem =(EditText) findViewById(R.id.editText_problem);
		
		PictureButton_workdialy = (PictureButton) findViewById(R.id.PictureButton_workdialy);
	}
	
	@Override
	public Boolean IsPassed() {
		if (super.IsPassed()) {
			if(!CheckEditStringMin5(editText_workplay, 10))
				return false;
			else
				return true;
		}else {
			return false;
		}
	}

}
